﻿@using Utilities;

@model Data.DBModels.Website



@using (Ajax.BeginForm("EditPopUp", "Website", new AjaxOptions() { HttpMethod = "Post", UpdateTargetId = @Model.Id.IsValid() ? @Model.Id.ToString() : "displayAllCategories" }))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Website</legend>

        @Html.HiddenFor(model => model.Id)


        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Url)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Url)
            @Html.ValidationMessageFor(model => model.Url)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div>


        <div class="editor-label">
            <div>Categories:</div>
        </div>


        <div>
            @Html.Action("CreateCategoriesDDL", "Category")
            <input type="button" id="btn_selectCategory" value="Select" />
        </div>


        <ul id="ul_selectedCategories">
            @if (Model.Categories != null)
            {
                foreach (Data.DBModels.Category cat in Model.Categories)
                {
                    <li>
                        <input type="hidden" class="selectedCategories" name="selectedCategories" value="@cat.Id" />
                        <div>@cat.Name</div>
                        <input type="button" class="deleteCategoryBtn" value="Delete" />
                    </li>
                }
            }
        </ul>



        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>

}


